<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>后台管理</title>
    <link rel="stylesheet" th:href="@{../static/layui/css/layui.css}">
</head>

<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">后台管理</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <!-- 移动端显示 -->
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>

        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <img id="img" th:src="@{(${session.user.getPictureUrl()})}"
                         class="layui-nav-img">
                    <span th:text="${session.user.getUsername()}"></span>
                </a>
                <dl class="layui-nav-child">
                    <dd><a th:href="@{/user/detail/{id}(id=${session.user.getId()})}">个人信息</a></dd>

                    <dd><a th:href="@{/user/logout}">退出</a></dd>
                </dl>
            </li>

        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">

                <li class="layui-nav-item" th:if="${session.user.getRole()} eq 1 ">
                    <a>比赛管理</a>
                    <dl class="layui-nav-child">
                        <dd>
                            <a th:href="@{/match/list}" target="iframeMain">对战管理</a>
                        </dd>
                        <dd>
                            <a th:href="@{/match/control}" target="iframeMain">对战控制</a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item"><a href="user/userlist" target="iframeMain">用户管理</a></li>
                <li class="layui-nav-item"><a th:href="@{/score/toRanking}" target="iframeMain">排行统计</a></li>
                <li class="layui-nav-item" th:if="${session.user.getRole() eq 2}"><a id="score" th:href="@{/score/page} " target="iframeMain">评委打分</a></li>
                <li class="layui-nav-item" th:if="${session.user.getRole() eq 4}"><a id="vote" th:href="@{/vote/page}"  target="iframeMain">观众投票</a></li>
                <li class="layui-nav-item"><a id="show" onclick="showInBig()"  target="iframeMain">大屏显示</a></li>

            </ul>
        </div>
    </div>
    <div class="layui-body">
        <!-- 内容主体区域 -->
<!--        <h2 align="center">欢迎管理员</h2>-->

        <iframe name="iframeMain" style="width: 100%; height: 100%;"></iframe>
    </div>


</div>
<script th:src="@{../static/layui/layui.js}"></script>
<script th:src="@{../static/mysource/js/jquery-3.3.1.min.js}"></script>

<script>


    function showInBig(){
        $.ajax({
            url:"/show/verify",
            dataType:"json",
            type:"post",
            success:function (data){
                if (data.flag){
                    alert(data.msg);
                    location.href='/show/showList'
                }else {
                    alert(data.msg);
                    // location.reload()
                }
            }
        })
    }
    function scores(){
        $.ajax({
            url:"/show/verify",
            dataType:"json",
            type:"post",
            success:function (data){
                if (data.flag){
                    alert(data.msg);
                    location.href='/score/page'
                }else {
                    alert(data.msg);
                }
            }
        })
    }
    function vote(){
        $.ajax({
            url:"/show/verify",
            dataType:"json",
            type:"post",
            success:function (data){
                if (data.flag){
                    alert(data.msg);
                    location.href='/vote/page'
                }else {
                    alert(data.msg);
                }
            }
        })
    }

    //JS
    layui.use(['element', 'layer', 'util'], function () {
        var element = layui.element
            , layer = layui.layer
            , util = layui.util
            , $ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function (othis) {
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
            , menuRight: function () {
                layer.open({
                    type: 1
                    , content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                    , area: ['260px', '100%']
                    , offset: 'rt' //右上角
                    , anim: 5
                    , shadeClose: true
                });
            }
        });

    });
</script>
</body>

</html>